package com.fram.common.util.wxpay;

import org.springframework.core.io.ClassPathResource;

import java.io.*;

public class MyWxPayConfig extends WXPayConfig {

	@SuppressWarnings("unused")
	private byte[] certData;
	private String appId;
	private String mchId;
	private String key;

	public String getAppID() {
		return this.appId;
	}

	public void setAppId(String appId) {
		this.appId = appId;
	}

	public String getMchID() {
		return mchId;
	}

	public void setMchId(String mchId) {
		this.mchId = mchId;
	}

	public String getKey() {
		return key;
	}

	public void setKey(String key) {
		this.key = key;
	}

	public InputStream getCertStream() throws IOException {
		ClassPathResource resource = new ClassPathResource("/cret/apiclient_cert.p12");
		InputStream inputStream = resource.getInputStream();
		return inputStream;
	}

	public int getHttpConnectTimeoutMs() {
		return 8000;
	}

	public int getHttpReadTimeoutMs() {
		return 10000;
	}

	@Override
	public IWXPayDomain getWXPayDomain() {
		IWXPayDomain iwxPayDomain = new IWXPayDomain() {
			@Override
			public void report(String domain, long elapsedTimeMillis, Exception ex) {

			}

			@Override
			public DomainInfo getDomain(WXPayConfig config) {
				return new IWXPayDomain.DomainInfo(WXPayConstants.DOMAIN_API, true);
			}
		};
		return iwxPayDomain;
	}

}
